#ifndef _IFILESERIALISABLE_H
#define _IFILESERIALISABLE_H

#include <string>

#include <exceptions/GSTRuntimeException.h>
#include <GSTenums.h>

namespace GST{
namespace Geometry{

class GST_API_EXPORT IFileSerialisable {	

public:
	enum FileType {
		GocadFile=1,
		DXF,
		OFF,
		OBJ,
		X3D,
		PLY2,
		SFS,
		SFSP,
		ArchiveFile,
		BIN,
		SURPAC_DTM,
		SUPRAC_STR,
		MockParse,
		KMZ,
		DAE,
        unkown,
        VTK,
        ISATIS,
        X3DOMPOP,
		I3S_SLPK,
		USDZ,
	};

	virtual void saveToFile(const std::string & filename, const FileType & filetype) = 0;
	virtual void loadFromFile(const std::string & filename, const FileType & filetype) = 0;
	static const char * FileTypeToExtsion( const FileType& type, Geometry::GeometryTypes geomtype = Geometry::unkown )
	{
		switch(type)
		{
		case GocadFile:
			switch(geomtype)
			{
			case Geometry::Multipoint3:
				return "vs";
			case Geometry::Multiline3:
				return "pl";
			case Geometry::Tin3:
				return "ts";
			case Geometry::Multipolygon3:
				return "so";
			case Geometry::Geomcollection3:
			default:
				return "gp";
			}
		case DXF:
			return "dxf";
		case OFF:
			return "off";
		case X3D:
			return "x3d";
		case PLY2:
			return "ply2";
		case SFS:
			return "wkt";
		case SFSP:
			return "SFSP";
		case OBJ:
			return "obj";
        case X3DOMPOP:
		case BIN:
			return "bin";
		case KMZ:
			return "kmz";
		case DAE:
			switch(geomtype)
			{
			case Geometry::Multipoint3:
			case Geometry::Multiline3:
				return "kml";
			case Geometry::Tin3:
			case Geometry::Multipolygon3:
			case Geometry::Geomcollection3:
			default:
				return "collada";
			}
        case VTK:
            return "vtk";
		case ISATIS:
			// TODO: ISATIS file extension
			// since server currently writes ".hd" we use that.
			return "hd";
		case I3S_SLPK:
			return "slpk";
		case USDZ:
			return "usd";
		default:
		case unkown:
			throw exceptions::GSTRuntimeException(__METHOD_NAME__,"Unknown file type.");
		}
	}

	static bool SupportMetaDataParsing(FileType & fileformat)
	{
		switch(fileformat)
		{
		case IFileSerialisable::GocadFile:
		case IFileSerialisable::MockParse:
			return true;
		default:
			return false;
		}
	}

	static std::string FileType2JsonSendingType( IFileSerialisable::FileType ftype )
	{
		switch(ftype)
		{
		case GocadFile:
			return "GCD";
		case DXF:
			return "DXF";
		case OFF:
			return "OFF";
		case OBJ:
			return "OBJ";
		case X3D:
			return "X3D";
		case PLY2:
			return "PLY2";
		case SFS:
			return "SFS";
		case SFSP:
			return "SFSP";
		case BIN:
			return "BIN";
		case SURPAC_DTM:
			return "SURPAC_DTM";
		case SUPRAC_STR:
			return "SURPAC_STR";
		case unkown:
			return "UNKNOWN";
        case VTK:
            return "VTK";
        case X3DOMPOP:
            return "X3DOMPOP";
		case I3S_SLPK:
            return "I3S_SLPK";
		case USDZ:
			return "USDZ";
		case ArchiveFile:
		default:
			throw exceptions::GSTRuntimeException(__METHOD_NAME__,"Can't write json file type for this geometry.");
		}
	}
};


}// namespace Geometry
}// namespace GST


#endif  //_IFILESERIALISABLE_H
